package com.android.accessibility.stat;

import java.util.Map;
import java.util.Properties;

import android.text.TextUtils;

import com.android.accessibility.utils.Log;
import com.android.accessibility.utils.Utils;
import com.tencent.stat.StatConfig;
import com.tencent.stat.StatReportStrategy;
import com.tencent.stat.StatService;

public class QQStat extends Stat {

    @Override
    public void init() {
        super.init();
        boolean debug = TextUtils.isEmpty(Utils.getReleaseTime(mContext));
        Log.d(Log.TAG, "debug : " + debug);
        StatConfig.setDebugEnable(debug);
        StatConfig.setAutoExceptionCaught(true);
        StatConfig.setStatSendStrategy(StatReportStrategy.APP_LAUNCH);
    }

    @Override
    public void onResume() {
        super.onResume();
        StatService.onResume(mContext);
    }

    @Override
    public void onPause() {
        super.onPause();
        StatService.onPause(mContext);
    }

    @Override
    public void reportKVEvent(String id,
            Map<String, Object> params) {
        super.reportKVEvent(id, params);
        if (params == null) {
            return;
        }
        Properties p = new Properties();
        for (Map.Entry<String, Object> keySet : params.entrySet()) {
            p.put(keySet.getKey(), keySet.getValue());
        }
        StatService.trackCustomKVEvent(mContext, id, p);
    }

    public void reportEvent(String id, String ...params) {
        StatService.trackCustomEvent(mContext, id, params);
    }

    public boolean disableAd() {
        String args = StatConfig.getCustomProperty("disablead");
        return "true".equals(args);
    }
}
